<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
        <title>Cadastro de Usuários</title>
    </h:head>
    <h:body>
        <h1>Cadastro de Usuários</h1>
        <h:form id="cadastro">
            <h:messages></h:messages>
            <h:inputHidden value="#{usuarioBean.usuario.codigo}"/>
            <h:inputHidden value="#{usuarioBean.usuario.ativo}"/>
            <h:inputHidden value="#{usuarioBean.destinoSalvar}"/>

            <h:panelGrid columns="2">
                <h:outputLabel value="Nome:" for="nome"/>
                <h:inputText id="nome" label="Nome" value="#{usuarioBean.usuario.nome}"
                             size="30" maxlength="30" required="true" requiredMessage="Insira seu nome!">
                    <f:validateLength minimum="10" maximum="30"/>
                </h:inputText>	

                <h:outputLabel value="Data Nascimento:" for="data"/>
                <h:inputText id="data" label="Data Nascimento" value="#{usuarioBean.usuario.nascimento}"
                             size="10" maxlength="10" required="false" requiredMessage="Insira sua data de nascimento!">
                    <f:convertDateTime dateStyle="default" type="date"/>
                </h:inputText>

                <h:outputLabel value="Celular:" for="celular"/>
                <h:inputText id="celular" label="Celular" value="#{usuarioBean.usuario.celular}" size = "10"/>

                <h:outputLabel value="e-Mail" for="email"/>
                <h:panelGroup>
                    <h:inputText id="email"
                                 label="e-Mail"
                                 value="#{usuarioBean.usuario.email}"
                                 size="50" maxlength="50" required="true"
                                 validatorMessage="e-Mail inválido">
                        <f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+"/>
                    </h:inputText>
                    <h:message for="email"/>
                </h:panelGroup>

                <h:outputLabel value="Idioma:" for="idioma"/>
                <h:selectOneMenu id="idioma" value="#{usuarioBean.usuario.idioma}">
                    <f:selectItem itemValue="pt_BR" itemLabel="Português"/>
                    <f:selectItem itemValue="en_US" itemLabel="English"/>
                    <f:selectItem itemValue="es_ES" itemLabel="Espanol"/>
                </h:selectOneMenu>

                <h:outputLabel value="Login:" for="login"/>
                <h:inputText id="login"
                             label="Login"
                             value="#{usuarioBean.usuario.login}"
                             size="15" maxlength="15" required="true"
                             validatorMessage="Login deve ter no m�nimo 5 e no m�ximo 15 caracteres e s� pode ter os 
                             s�mbolos '.' e '_'">
                    <f:validateRegex pattern="([a-z]|[0-9]|[.]|[_]){5,15}"/>
                </h:inputText>

                <h:outputLabel value="Senha:" for="senha"/>
                <h:inputSecret id="senha" label="Senha" value="#{usuarioBean.usuario.senha}" size="10"
                               maxlength="10" required="true" redisplay="true"/>

                <h:outputLabel value="Confirmar Senha:" for="confirmarsenha"/>
                <h:inputSecret id="confirmarsenha" label="Confirmar Senha" value="#{usuarioBean.confirmarSenha}"
                               size="10" maxlength="10" required="true" redisplay="true"/>
            </h:panelGrid>

            <h:commandButton action="#{usuarioBean.salvar}" value="Salvar"/>
        </h:form>
    </h:body>
</html>